<template>
    <div class="buycart">
        <navbar class="nav-bar">
            <template v-slot:left>
                <div @click="back">
                    <van-icon name="arrow-left" size="30" />
                </div>
            </template>
            <template v-slot:center>
                <div style="font-size: 0.5rem;font-weight: 500;">已购买</div>
            </template>
        </navbar>

        <!-- 购买商品 -->
        <!-- 购物商品卡片 -->
        <div>
            <div id="shop-item" v-for="(item, index) in buygoods" :key="index">

                <div class="item-img">
                    <img :src="item.image" alt="商品图片">
                </div>

                <div class="item-info">
                    <div class="item-title">{{ item.title }}</div>
                    <div class="item-desc">商品描述: {{ item.desc }}</div>

                    <div class="info-bottom">
                        <div class="item-price left">¥{{ item.price }}</div>
                        <div class="item-count right" style="color: red;">
                            购买数量{{ item.count }}，已付款
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
</template>

<script setup>
import navbar from '../../components/navbar.vue'
import { reactive, computed} from 'vue'
import { useStore } from 'vuex' // 引入useStore 方法
import router from '../../router';
const store = useStore()  // 该方法用于返回store 实例

let data = reactive({

})


let buygoods = computed(() => {
    return store.getters.getbuygoods
})
console.log('buygoods', buygoods);

let back=()=>{
    router.replace('/profile')
}



</script>

<style scoped>
.buycart {
    height: 100vh;
    position: relative;
    z-index: 9999;
    background-color: #fff;
}

.nav-bar {
    background-color: var(--color-tint);
    font-weight: 700;
    color: #fff;
}

.delete-button {
    height: 100%;
}

#shop-item {
    width: 100%;
    display: flex;
    padding: 5px;
    border-bottom: 1px solid #ccc;
}

.bu {
    width: 20px;
    height: 25px;

}

.van-submit-bar {
    bottom: 2.0033rem;
}

.shou {
    display: flex;
    margin-left: 15px;
    margin-top: 15px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid #ccc;

}

.item-selector {
    width: 14%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.item-title,
.item-desc {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-img {
    padding: 5px;
    /*border: 1px solid #ccc;*/
}

.item-img img {
    width: 80px;
    height: 100px;
    display: block;
    border-radius: 5px;
}

.item-info {
    font-size: 17px;
    color: #333;
    padding: 5px 10px;
    position: relative;
    overflow: hidden;
}

.item-info .item-desc {
    font-size: 14px;
    color: #666;
    margin-top: 15px;
}

.info-bottom {
    margin-top: 10px;
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
}

.info-bottom .item-price {
    color: orangered;
}
</style>